<?php

namespace app\admin\model\shopro;

use app\admin\model\shopro\user\User;
use app\common\model\MoneyLog;
use app\common\model\ScoreLog;
use think\Model;

class Pclog extends Model
{

    // 表名
    protected $name = 'shopro_pc_log';
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';
    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = '';
    // 追加属性
    protected $append = [
        'type_text'
    ];
    protected $type = [
        'ext' => 'json',
    ];
    protected $typeMap  = [
        '0' => '订单',
        '1' => '充正',
        '2' => '平级奖',
        '3' => '分红接力赛',
        '4' => '充值余额',
    ];
    public function getTypeTextAttr($value, $data)
    {
        return $this->typeMap[$data['type']] ?? '';
    }
    public function user()
    {
        return $this->belongsTo(User::class, 'user_id', 'id');
    }
}
